package com.jy.web.diy.controller;

import java.io.IOException;
import java.util.Arrays;
import java.util.Map;

import com.jy.framework.annotation.RequiresAction;
import com.jy.framework.annotation.SysLog;
import com.jy.framework.sys.entity.SysMenuEntity;
import com.jy.framework.sys.service.SysMenuService;
import com.jy.framework.validator.ValidatorUtils;
import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.jy.framework.base.BaseController;

import com.jy.web.diy.entity.CategoryEntity;
import com.jy.web.diy.service.CategoryService;
import com.jy.framework.utils.PageUtils;
import com.jy.framework.utils.R;

import javax.servlet.http.HttpServletResponse;


/**
 * 分类表
 *
 * @author JuiceYan
 * @email JuiceYan@jy.com
 * @date 2018-12-22 20:55:33
 */
@Api(tags = "分类表")
@RestController
@RequestMapping("diy/category")
public class CategoryController extends BaseController<CategoryService, CategoryEntity> {
    @Autowired
    private SysMenuService sysMenuService;

    /**
     * 添加自定义模块菜单
     */
    @SysLog("添加自定义模块菜单")
    @RequestMapping("/addCategoryMenu")
    @RequiresAction("save")
    public R addCategoryMenu(@RequestBody SysMenuEntity menu) {
        menu.setPerms("CategoryController:save");
//        自定义模块默认上级
        menu.setParentId(257L);
//        默认是菜单
        menu.setType(1);
        //数据校验
        ValidatorUtils.validateEntity(menu);
        sysMenuService.save(menu);
        return R.ok();
    }

}